package com.airport.schedule.util;

import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtils {

    public static boolean isEmpty(String str) {
        return str == null || str.equals("");
    }

    private static Pattern numberAlphabetPattern = Pattern.compile("[a-zA-Z0-9]+");

    public static boolean checkAllNumberOrAlphabet(Collection<String> collection) {
        for(String s : collection) {
            if(!numberAlphabetPattern.matcher(s).matches())
                return false;
        }
        return true;
    }

    public static boolean checkAllNumberOrAlphabet(String str) {
        return numberAlphabetPattern.matcher(str).matches();
    }

    private static Pattern numberPattern = Pattern.compile("[0-9]+");

    public static Pair<Integer, Integer> extractFromTo(String str) {
        Matcher matcher = numberPattern.matcher(str);
        matcher.find();
        String from = matcher.group();
        matcher.find();
        String to = matcher.group();
        return new Pair<>(Integer.valueOf(from), Integer.valueOf(to));
    }

    public static void main(String args[]) {
        System.out.println(extractFromTo("阻挡415至429机位上航班的滑入"));
    }

}
